package com.yang.library.service;

import com.yang.library.service.bookthread.ServiceThread;
import com.yang.library.util.Constant;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class AppService {
    public static void main(String[] args) throws Exception {
        System.out.println("======图书管理系统服务端启动======");
        ServerSocket serverSocket = new ServerSocket(Constant.SERVER_PORT);
        while (true) {
            try {
                // 创建图书管理系统服务端对象
                Socket socket = serverSocket.accept();
                System.out.println("客户端:" + socket.getInetAddress().getHostAddress()
                        + "端口号:" + socket.getPort());
                new ServiceThread(socket).start();
            } catch (IOException e) {
                System.out.println("服务端启动异常");
                throw new RuntimeException(e);
            }
        }
    }
}
